import Vue from "vue";
import Vuex from "vuex";

import aaa from 'vuex-persistedstate'
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    wwc: [],
    yqxs: [],
    ywc: [],
  },
  mutations: {
    zms_wwc(state, obj) {
      state.wwc.push(obj)
    },
    // 从未完成转到已取消
    wwc(state, obj) {
      state.yqxs.push(obj)
    },
    // 删除未完成
    rem_wwc(state, index) {
      // console.log(index);
      state.wwc.splice(index, 1)
    },
    // 从未完成到已完成
    zms_ywc(state, obj) {
      state.ywc.push(obj)
    },
    //从未完成删除
    rem(state, index) {
      state.wwc.splice(index, 1)
    },
    //从已完成删除
    rem_ywc(state, index) {
      state.ywc.splice(index, 1)
    },
    // 从已取消恢复到未完成
    hf(state, obj) {
      state.wwc.push(obj)
    },
    // 从已取消删除
    rem_yqx(state, index) {
      console.log(index);
      state.yqxs.splice(index, 1)
    }
  },
  actions: {},
  modules: {},
  getters: {
    // 计算属性
    // cont(state) {
    //   var cont = 0;
    //   state.good.forEach(item => {
    //     cont += item.price * item.num
    //   })
    //   return cont;
    // }
  },
  plugins: [aaa()],//引入插件
});
